﻿using UnityEngine;
using System.Collections;

public class MenuScene : MonoBehaviour {
	
	//public Renderer BlackThing;
		bool readyToLoad = false;
	
	public AudioClip clickSound;
	public AudioSource BGMPlayer;
	// Use this for initialization
	void Start () {
		//PlayerPrefs.DeleteAll();
	}
	
	// Update is called once per frame
	void Update () {
		
		if(readyToLoad)
		{
			Color tmpCol = renderer.material.color;
			tmpCol.a += Time.deltaTime * 0.6f;
			renderer.material.color = tmpCol;
			BGMPlayer.volume -= Time.deltaTime * 0.4f;
			if(tmpCol.a >= 1.0f)
			{
				if(DataScript.IsGameState(GAMESTATE.ISFIRSTLOGIN) == 0)
					Application.LoadLevel("CreateCharacterSceen");
				else
					Application.LoadLevel("LobbyScene");
			}
		}
		else
		{ 
			Color tmpCol = renderer.material.color;
			tmpCol.a -= Time.deltaTime * 0.6f;
			renderer.material.color = tmpCol;
			if(tmpCol.a <= 0f)
			{
				if(Input.anyKeyDown)
				{
					audio.PlayOneShot(clickSound);
					//Debug.Log("TRUE");
					readyToLoad = true;
					tmpCol.a = 0;
					renderer.material.color = tmpCol;
				}
			}
		}
		
		
	}
}
